package ch.dice.fxml;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Circle;

public class FXMLDocumentController
{

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;
    
    @FXML
    private Circle c1, c2, c3, c4, c5, c6, c7;

    @FXML
    void handleButtonAction(MouseEvent event)
    {
        roll();
    }

    public void roll()
    {
        for (int i = 1; i <= 7; i++)
        {
            setVisible(i, false);
        }

        int nr = (int) (Math.random() * 6) + 1;
        System.out.println(nr);
        setEyes(nr);
    }

    public void setEyes(int eyes)
    {
        switch (eyes)
        {
            case 6:
                setVisible(2, true);
                setVisible(6, true);
            case 4:
                setVisible(3, true);
                setVisible(5, true);
            case 2:
                setVisible(1, true);
                setVisible(7, true);
                break;
            case 5:
                setVisible(1, true);
                setVisible(7, true);
            case 3:
                setVisible(3, true);
                setVisible(5, true);
            case 1:
                setVisible(4, true);
                break;
        }
    }

    public void setVisible(int eye, boolean visible)
    {
        switch (eye)
        {
            case 1:                
                c1.setVisible(visible);
                break;
            case 2:
                c2.setVisible(visible);
                break;
            case 3:
                c3.setVisible(visible);
                break;
            case 4:
                c4.setVisible(visible);
                break;
            case 5:
                c5.setVisible(visible);
                break;
            case 6:
                c6.setVisible(visible);
                break;
            case 7:
                c7.setVisible(visible);
                break;
        }
    }
}
